{% extends 'base.html' %}
{% load humanize %}
{% block page-content %}
{% include 'nav_cat_bar.html' %}

<div class="wrapper wrapper-content animated fadeInRight">
<div class="row">
<div class="col-lg-12">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>角色管理 </h5>
            <div class="ibox-tools">
                <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                </a>
                <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                    <i class="fa fa-wrench"></i>
                </a>
                <ul class="dropdown-menu dropdown-user">
                    <li><a href="#">Config option 1</a>
                    </li>
                    <li><a href="#">Config option 2</a>
                    </li>
                </ul>
                <a class="close-link">
                    <i class="fa fa-times"></i>
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <div class="row">
              <div class="col-sm-4 m-b-xs">
                  <button type="button" class="btn btn-primary btn-sm" data-toggle="modal" data-target="#dept_add"><i class="icon-cogs"></i>新建角色</button>
              </div>
            </div>
            <div class="table-responsive">
                <table class="table table-striped table-bordered table-hover">
                    <thead>
                    <tr>
                        <th class="text-center">角色名称</th>
                        <th class="text-center">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    {% for role in role_info %}
                          <tr class="text-center">
                            <td>{{ role.name}}</td>
                            <td>
                                <a href="/manager/role_edit/?role_id={{role.id}}"><span class="glyphicon glyphicon-pencil"></span></a>
                                <a href="/manager/role_list/?role_name={{role.name}}&action=delete"><span class="glyphicon glyphicon-trash" style="color:red" onclick="return confirm('确认删除吗？')"></span></a>
                            </td>

                          </tr>
                         {% endfor %}
                    </tbody>
                </table>
                {% if error %}
                    <div class="alert alert-warning text-center">{{ error }}</div>
                {% endif %}
                {% if add_info %}
                    <div class="alert alert-success text-center">{{ add_info }}</div>
                {% endif %}
               <div class="col-sm-6">
                    <div class="dataTables_info" id="editable_info" role="status" aria-live="polite">
                          Showing {{ contacts.start_index }} to {{ contacts.end_index }} of {{ p.count }} entries
                    </div>
                </div>
                   {% include 'paginator.html' %}
                </div>
    </div>
</div>
</div>
</div>
</div>

<div class="modal fade" id="dept_add" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="exampleModalLabel" align="center">添加角色</h4>
</div>
<div class="modal-body">
<form id="role_form" method="post" class="form-horizontal" action="">
<div class="form-group">
<label for="group_name" class="col-sm-2 control-label">角色名称<span class="red-fonts">*</span></label>
<div class="col-sm-8">
<input id="role_name" name="role_name" placeholder="Group name" type="text" class="form-control" >
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
<button type="submit" class="btn btn-primary" form="role_form" formmethod="post" formaction="{% url 'role_list' %}" name="action" value="add">确定</button>
</div>
</div>
</div>
</div>


{% endblock %}
